package com.sitech.portal.server.dao.ibatis;

import java.util.List;
import java.util.Map;

import com.sitech.ibnms.core.BaseIbnmsDao;
import com.sitech.portal.server.dao.ISysLinkDao;
import com.sitech.portal.util.CommUtil;

public class SysLinkDaoImpl extends BaseIbnmsDao implements ISysLinkDao {

	public static final String CENTER = "CENTER";
    public static final String BASIC_MANAGEMENT = "BASIC_MANAGEMENT";

    /**
     * 根据类别获取LINK
     * @param LINK_TYPE
     * @param login_id
     * @return
     */
    public List<Map> queryTB_SYS_LINKByType(String LINK_TYPE, String login_id) {
        StringBuilder sql = new StringBuilder();
        sql.append("select * from TB_SYS_LINK l where l.LINK_TYPE = '").append(LINK_TYPE).append("' ");
        if (!CommUtil.USER_ADMIN.equals(login_id)) { //权限控制
            sql.append(" and exists( select rm.MODULE_ID from TB_SYS_ROLE_MODULE rm join TB_SYS_USER_ROLE ur on ur.ROLE_ID = rm.ROLE_ID and ur.LOGIN_ID = '").append(login_id).append("'  where rm.MODULE_ID = l.LINK_ID) ");
        }
        sql.append(" order by l.LINK_ORDER ");
        return this.query("queryForHashMap", sql.toString());
    }
}
